package com.xishu.entity.shop;

import com.xishu.annotation.dao.DefaultValue;
import com.xishu.annotation.dao.FieldMapping;
import com.xishu.annotation.dao.ResponseFormat;
import com.xishu.annotation.dao.Search;
import com.xishu.annotation.valid.UniqueName;
import com.xishu.entity.AbstractEntity;
import com.xishu.entity.ShopItem;
import com.xishu.entity.oplog.OpName;
import io.swagger.annotations.ApiModelProperty;

import javax.persistence.*;
import java.util.List;

@Entity(name = "scene")
@Table(indexes = {@Index(columnList = "shopId")})
public class Scene extends ShopItem implements OpName {
    private static final long serialVersionUID = 9050414577733342489L;

    @Transient
    private String opName;

    @ApiModelProperty(value = "场景名称")
    @UniqueName(union = true)
    private String name;

    @ApiModelProperty(value = "场景归属的公司")
    private Long companyId;

    @ApiModelProperty(value = "场景归属的分店")
    @UniqueName(union = true)
    private Long shopId;

    @ApiModelProperty(value = "场景归属的分店")
    private String shopName;

    @Transient
    @ApiModelProperty(value = "场景归属的分店")
    private String shopName_zh;

    @Transient
    @ApiModelProperty(value = "场景归属的分店")
    private String shopName_en;

    @ApiModelProperty(value = "是否启用")
    private Boolean enable;

    @ApiModelProperty(value = "应用时间段配置,当前一个配置所有的星期XXX对应一个时间段，服务器端会做成动态的，支持每个星期XXX时间段不同")
    @Transient
    @FieldMapping(desField = "timeConfigJson", serialize = true)
    private List<SceneTimeConfig> timeConfigList;

    @FieldMapping(desField = "timeConfigList", serialize = false, genericType = "com.xishu.entity.shop.SceneTimeConfig")
    @Column(length = 2048)
    private String timeConfigJson;

    @Transient
    @Search(in = true, fieldName = "shopId")
    private transient List<Long> shopIdList;

    @Transient
    @FieldMapping(desField = "runModuleSceneJson", serialize = true)
    @DefaultValue(defaultValue = "")
    private List<RunModuleScene> runModuleSceneList;

    @FieldMapping(desField = "runModuleSceneList", serialize = false, genericType = "com.xishu.entity.shop.RunModuleScene")
    @Column(length = 2048)
    private String runModuleSceneJson;

    @ApiModelProperty(value = "餐桌配置id")
    private Long foodTableConfigId;

    @ApiModelProperty(value = "餐桌配置index")
    private Integer foodTableConfigIndex;


    @ApiModelProperty(value = "服务费的比例,输入整数")
    private Double serviceFeePercent;

    //美国版本的外卖折扣，因为需要到小数点后3位，所以不做特殊处理
    @ApiModelProperty(value = "外卖打折比例,直接输入XX折，比如7.5折")
    @ResponseFormat(doubleDigitNumber = 3, version = "us")
    private Double takeoutFeePercent;

    @ApiModelProperty(value = "B端发送厨房自动打印客票")
    @DefaultValue(defaultValue = "false")
    private Boolean sendToKitchenAutoPrintOrderInB;

    @ApiModelProperty(value = "C端发送厨房自动打印客票")
    @DefaultValue(defaultValue = "false")
    private Boolean sendToKitchenAutoPrintOrderInC;

    @ApiModelProperty(value = "C端结账之后，自动打印")
    @DefaultValue(defaultValue = "false")
    private Boolean printOrderWhenPayedOrderInC;

    @ApiModelProperty(value = "小费")
    @DefaultValue(defaultValue = "false")
    private Boolean tip;

    @ApiModelProperty(value = "服务费取舍标准，1：向下取整，2：四舍五入，3：向上取整")
    @DefaultValue(defaultValue = "2")
    private Integer serviceRound;

    public Integer getServiceRound() {
        return serviceRound;
    }

    public void setServiceRound(Integer serviceRound) {
        this.serviceRound = serviceRound;
    }

    public Boolean getPrintOrderWhenPayedOrderInC() {
        return printOrderWhenPayedOrderInC;
    }

    public void setPrintOrderWhenPayedOrderInC(Boolean printOrderWhenPayedOrderInC) {
        this.printOrderWhenPayedOrderInC = printOrderWhenPayedOrderInC;
    }

    public String getShopName_zh() {
        return shopName_zh;
    }

    public void setShopName_zh(String shopName_zh) {
        this.shopName_zh = shopName_zh;
    }

    public String getShopName_en() {
        return shopName_en;
    }

    public void setShopName_en(String shopName_en) {
        this.shopName_en = shopName_en;
    }

    public Boolean getTip() {
        return tip;
    }

    public void setTip(Boolean tip) {
        this.tip = tip;
    }

    public Double getServiceFeePercent() {
        return serviceFeePercent;
    }

    public void setServiceFeePercent(Double serviceFeePercent) {
        this.serviceFeePercent = serviceFeePercent;
    }

    public Double getTakeoutFeePercent() {
        return takeoutFeePercent;
    }

    public void setTakeoutFeePercent(Double takeoutFeePercent) {
        this.takeoutFeePercent = takeoutFeePercent;
    }

    public Boolean getSendToKitchenAutoPrintOrderInB() {
        return sendToKitchenAutoPrintOrderInB;
    }

    public void setSendToKitchenAutoPrintOrderInB(Boolean sendToKitchenAutoPrintOrderInB) {
        this.sendToKitchenAutoPrintOrderInB = sendToKitchenAutoPrintOrderInB;
    }

    public Boolean getSendToKitchenAutoPrintOrderInC() {
        return sendToKitchenAutoPrintOrderInC;
    }

    public void setSendToKitchenAutoPrintOrderInC(Boolean sendToKitchenAutoPrintOrderInC) {
        this.sendToKitchenAutoPrintOrderInC = sendToKitchenAutoPrintOrderInC;
    }

    public Integer getFoodTableConfigIndex() {
        return foodTableConfigIndex;
    }

    public void setFoodTableConfigIndex(Integer foodTableConfigIndex) {
        this.foodTableConfigIndex = foodTableConfigIndex;
    }

    public Long getFoodTableConfigId() {
        return foodTableConfigId;
    }

    public void setFoodTableConfigId(Long foodTableConfigId) {
        this.foodTableConfigId = foodTableConfigId;
    }

    public List<RunModuleScene> getRunModuleSceneList() {
        return runModuleSceneList;
    }

    public void setRunModuleSceneList(List<RunModuleScene> runModuleSceneList) {
        this.runModuleSceneList = runModuleSceneList;
    }

    public String getRunModuleSceneJson() {
        return runModuleSceneJson;
    }

    public void setRunModuleSceneJson(String runModuleSceneJson) {
        this.runModuleSceneJson = runModuleSceneJson;
    }

    public List<Long> getShopIdList() {
        return shopIdList;
    }

    public void setShopIdList(List<Long> shopIdList) {
        this.shopIdList = shopIdList;
    }

    public String getTimeConfigJson() {
        return timeConfigJson;
    }

    public void setTimeConfigJson(String timeConfigJson) {
        this.timeConfigJson = timeConfigJson;
    }

    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public String getName() {
        return name;
    }

    @Override
    public String getOpName() {
        return opName;
    }

    @Override
    public void setOpName(String opName) {
        this.opName = opName;
    }

    @Override
    public String opType() {
        return "场景";
    }

    @Override
    public String[] fieldName() {
        return new String[]{"shopId", "name"};
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }

    public List<SceneTimeConfig> getTimeConfigList() {
        return timeConfigList;
    }

    public void setTimeConfigList(List<SceneTimeConfig> timeConfigList) {
        this.timeConfigList = timeConfigList;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Scene{");
        sb.append("opName='").append(opName).append('\'');
        sb.append(", name='").append(name).append('\'');
        sb.append(", companyId=").append(companyId);
        sb.append(", shopId=").append(shopId);
        sb.append(", shopName='").append(shopName).append('\'');
        sb.append(", enable=").append(enable);
        sb.append(", timeConfigList=").append(timeConfigList);
        sb.append(", timeConfigJson='").append(timeConfigJson).append('\'');
        sb.append(", shopIdList=").append(shopIdList);
        sb.append(", runModuleSceneList=").append(runModuleSceneList);
        sb.append(", runModuleSceneJson='").append(runModuleSceneJson).append('\'');
        sb.append(", foodTableConfigId=").append(foodTableConfigId);
        sb.append(", foodTableConfigIndex=").append(foodTableConfigIndex);
        sb.append(", serviceFeePercent=").append(serviceFeePercent);
        sb.append(", takeoutFeePercent=").append(takeoutFeePercent);
        sb.append(", sendToKitchenAutoPrintOrderInB=").append(sendToKitchenAutoPrintOrderInB);
        sb.append(", sendToKitchenAutoPrintOrderInC=").append(sendToKitchenAutoPrintOrderInC);
        sb.append(", tip=").append(tip);
        sb.append('}');
        return sb.toString();
    }
}
